package com.guli.auth.vo;

import com.guli.common.constant.AuthServerConstant;
import com.guli.common.valid.AddGroup;
import com.guli.common.valid.LoginGroup;
import lombok.Data;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.Null;
import javax.validation.constraints.Pattern;

/*
 * @Author 罗
 * @date 2020/10/18 - 3:52 下午
 */
@Data
public class UserVo {

    @Null(groups = {AddGroup.class, LoginGroup.class})
    private Long id;

    @NotEmpty(groups = {AddGroup.class, LoginGroup.class}, message = "用户名不能为空")
    @Length(groups = {AddGroup.class, LoginGroup.class}, message = "用户名长度需要在6～18位之间", min = 6, max = 18)
    private String username;

    @NotEmpty(groups = {AddGroup.class, LoginGroup.class})
    @Length(groups = {AddGroup.class, LoginGroup.class}, min = 6, max = 20, message = "密码长度必须在6~20位之间")
    private String password;

    @NotEmpty(groups = AddGroup.class)
    @Pattern(regexp = AuthServerConstant.PHONE_NUMBER_REGEX, message = "请输入正确的手机号", groups = {AddGroup.class})
    private String phoneNumber;

    @NotEmpty(message = "验证码不能为空", groups = {AddGroup.class})
    @Length(min = 4, max = 4, message = "验证码的长度只能是4位", groups = AddGroup.class)
    private String verificationCode;
}
